package thinking.java.initalization.and.clean.up.example;

/**
 * @author GaoFeng
 * @date 2020/1/2 12:59
 */
public class Ex_5_5_3_FinalizeTest {

    public static void main(String[]  args) {
        Ex_5_5_3_FinalizeTest finalizeTest = new Ex_5_5_3_FinalizeTest();
        System.out.println("将对象的引用赋为null");
        finalizeTest = null;
        System.out.println("开始通知JVM清理无用的对象");
        System.gc();
        System.out.println("清理完毕");
    }

    @Override
    protected void finalize() throws Throwable {
        System.out.println("对象将要被清理");
        super.finalize();
    }
}
